package com.ruoyi.baoming.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.baoming.domain.PoliticalStatus;
import com.ruoyi.baoming.service.IPoliticalStatusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 政治面貌信息Controller
 * 
 * @author xiaosong
 * @date 2024-11-20
 */
@Api(tags = "基础管理-政治面貌")
@RestController
@RequestMapping("/baoming/status")
public class PoliticalStatusController extends BaseController
{
    @Autowired
    private IPoliticalStatusService politicalStatusService;

    /**
     * 查询政治面貌信息列表
     */
    @PreAuthorize("@ss.hasPermi('baoming:status:list')")
    @ApiOperation("政治面貌信息管理 - 分页查询列表")
    @GetMapping("/list")
    public TableDataInfo list(PoliticalStatus politicalStatus)
    {
        startPage();
        List<PoliticalStatus> list = politicalStatusService.selectPoliticalStatusList(politicalStatus);
        return getDataTable(list);
    }

    /**
     * 导出政治面貌信息列表
     */

    @PreAuthorize("@ss.hasPermi('baoming:status:export')")
    @Log(title = "政治面貌信息", businessType = BusinessType.EXPORT)
    @ApiOperation("政治面貌信息管理 - 导出数据")
    @PostMapping("/export")
    public void export(HttpServletResponse response, PoliticalStatus politicalStatus)
    {
        List<PoliticalStatus> list = politicalStatusService.selectPoliticalStatusList(politicalStatus);
        ExcelUtil<PoliticalStatus> util = new ExcelUtil<PoliticalStatus>(PoliticalStatus.class);
        util.exportExcel(response, list, "政治面貌信息数据");
    }

    /**
     * 获取政治面貌信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:status:query')")
    @ApiOperation("政治面貌信息管理 - 根据ID获取详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(politicalStatusService.selectPoliticalStatusById(id));
    }

    /**
     * 新增政治面貌信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:status:add')")
    @Log(title = "政治面貌信息", businessType = BusinessType.INSERT)
    @ApiOperation("政治面貌信息管理 - 新增数据")
    @PostMapping
    public AjaxResult add(@RequestBody PoliticalStatus politicalStatus)
    {
        return toAjax(politicalStatusService.insertPoliticalStatus(politicalStatus));
    }

    /**
     * 修改政治面貌信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:status:edit')")
    @Log(title = "政治面貌信息", businessType = BusinessType.UPDATE)
    @ApiOperation("政治面貌信息管理 - 修改数据")
    @PutMapping
    public AjaxResult edit(@RequestBody PoliticalStatus politicalStatus)
    {
        return toAjax(politicalStatusService.updatePoliticalStatus(politicalStatus));
    }

    /**
     * 删除政治面貌信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:status:remove')")
    @Log(title = "政治面貌信息", businessType = BusinessType.DELETE)
	@ApiOperation("政治面貌信息管理 - 删除数据")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(politicalStatusService.deletePoliticalStatusByIds(ids));
    }
}
